home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / nasanets.zip / LAYER.H < prev    next >
Text File  |  1990-06-07  |  6KB  |  110 lines

  1.  
  2. /*=============================*/
  3. /*           NETS              */
  4. /*                             */
  5. /* a product of the AI Section */
  6. /* NASA, Johnson Space Center  */
  7. /*                             */
  8. /* principal author:           */
  9. /*       Paul Baffes           */
  10. /*                             */
  11. /* contributing authors:       */
  12. /*      Bryan Dulock           */
  13. /*      Chris Ortiz            */
  14. /*=============================*/
  15.  
  16.  
  17. /*
  18. ----------------------------------------------------------------------
  19.   LAYER MODULE  
  20. ----------------------------------------------------------------------
  21.   A layer is defined in this system as a grouping of nodes which are  
  22.    treated in a uniform manner.  This is similar to the slab concept  
  23.    put forth by Hinton in his discussion of the Boltzman machine.     
  24.   In the generalized delta concept, all that is necessary is that     
  25.    all of the connections between nodes by unidirectional, and that   
  26.    no cycles be placed in the graph.  Nothing, however, is stated     
  27.    which requires that all nodes within a layer be connected to all   
  28.    nodes in another layer; weights between layers are node-to-node.   
  29.    However, to keep things simple, we decided NOT to detail each node 
  30.    connection, but rather treat all nodes of a layer identically.     
  31.   At a later time, control over particular nodes may be desirable,    
  32.    and I would suggest that a new type (and module) be created for    
  33.    the concept of a NODE at that time.                                
  34. ----------------------------------------------------------------------
  35.   4-4-88 I've added a new feature which allows the connections be-    
  36.    tween layers to be more flexible than the strict connect-all       
  37.    scheme. The idea is that each layer is given dimensional info, as  
  38.    though it represented a grid.  Then, two layers can be connected   
  39.    via smaller rectangular "maps" which map several nodes "close      
  40.    together" in the larger layer to one node in the smaller layer.    
  41.    These mappings can also overlap. Anyway, the upshot is that the    
  42.    layer information must be stored somewhere, and this is the most   
  43.    appropriate spot, in the X_dim and Y_dim elements.                 
  44. ----------------------------------------------------------------------
  45.   4-6-89 Interesting! Almost a year later to the day I'm adding another
  46.    change to the layer structure. Anyway, there are two new additions
  47.    to the layer structure: "node_bias" and "prev_deltaB". Apparently I
  48.    had some difficulty understanding all the theory outlined by Rumelhart
  49.    in the PDP book since I left out the bias term. It functions exactly
  50.    like a weight, but with one difference. The bias is assumed to be
  51.    "connected" from an imaginary incoming node whose value is always 
  52.    1.0 to the node in question. Thus the bias term is exactly that: it
  53.    biases the final dot product sum before it is fed through the 
  54.    activation function.
  55. ----------------------------------------------------------------------
  56.   4-12-89 today I'm adding another element to the layer structure. This
  57.    is in response to the idea that each layer might well be best treated
  58.    as having a unique learning rate. In part this arises out of work on
  59.    the spectrum problem, where the number of connections between different
  60.    layers varies from 1200 to 30. The large range makes small weight
  61.    changes drastic for one layer and insignificant for another. The
  62.    "max_incoming" integer indicates the maximum weights coming into the
  63.    layer.
  64. ----------------------------------------------------------------------
  65.   4-13-89 Because there is some debate as to whether or not each layer
  66.    should have its own learning rate, I have moved the three structure
  67.    elements regarding learning to this layer structure from the net 
  68.    structure.
  69. ----------------------------------------------------------------------
  70. */
  71. typedef struct layer_str {
  72.    int    ID;                    /* identification number for layer      */
  73.    int    num_nodes;             /* num of nodes in the layer            */
  74.    int    max_incoming;          /* max weights coming into the layer    */
  75.    int    X_dim;                 /* X dimension of the layer             */
  76.    int    Y_dim;                 /* Y dimension of the layer             */
  77.    D_Sint cur_learn;             /* current learning rate for layer      */
  78.    float  learn_base;            /* base learning rate for layer         */
  79.    float  learn_scale;           /* scale for learning rate if csc used  */
  80.    float  momentum;              /* momentum for layer                   */
  81.    Sint   *node_outputs;         /* An array of Sint's, size = num_nodes */
  82.    Sint   *node_deltas;          /* as above, but for delta values       */
  83.    Sint   *node_bias;            /* as above, but for bias values        */
  84.    Sint   *prev_deltaB;          /* as above, but for last bias change   */
  85.    struct weights_lst_str  *in_weights;
  86.                                  /* ptr to a list of weights which have  */
  87.                                  /* this layer as their target           */
  88.    struct weights_lst_str  *out_weights; 
  89.                                  /* ptr to a list of weights which have  */
  90.                                  /* this layer as their source           */
  91. } Layer;
  92.  
  93.  
  94. /*
  95. -----------------------------------------------------------------------
  96.  the following is a structure for keeping a doubly linked list of the  
  97.   layers in the net.  This list should be created in the order that    
  98.   the layers should be evaluated for forward propagation.  Then, of    
  99.   course, backward propigation can be done in the reverse order.  Thus 
  100.   the list needs to be doubly linked so that one may move through it   
  101.   in either order.                                                     
  102. -----------------------------------------------------------------------
  103. */
  104. typedef struct layer_lst_str {
  105.    Layer                 *value;  /* a ptr to a layer                    */
  106.    struct layer_lst_str  *prev;   /* ptr to previous element in the list */
  107.    struct layer_lst_str  *next;   /*  "   "   next     "      "  "    "  */
  108. } Layer_lst;
  109.  
  110.